const app = {
  state: {
    name: '',
    examineData: [],
    questionsData: [],
    getDetail: {},
  },
  mutations: {
    SET_NAME: (state, name) => {
      state.name = name
    },
    //获得试题审核列表
    setDate(state,getlist){
      state[getlist.changeList] = getlist.setlist
    },
    //获得试题详情
    getDetails(state,detail){
      state.getDetail = detail
      console.log(state.getDetail);
    }
  },
  actions: {
    setName({ commit }, userInfo) {
      const username = userInfo.username.trim()
      return new Promise((resolve, reject) => {
        commit('SET_NAME', username)
        resolve()
      })
    },
    // 获得审核列表
    async getExamine(state,lists){
      const getlist = await lists.choice(lists.query)
      state.commit('setDate',{
        setlist: getlist.data,
        changeList: 'examineData'
      })
    },
    //获得组题列表
    async getQuestions(state,lists){
      const getlist = await lists.randoms(lists.query)
      state.commit('setDate',{
        setlist: getlist.data,
        changeList: 'questionsData'
      })
    },
    //获得试题详情
    async testQuestions(state,details) {
      const getlist = await details.detail(details)
      state.commit('getDetails',getlist.data)
    }
  }
}

export default app
